package com.ccnu.sm.aop;/*
 * @author raohj
 * @date 2019/12/1819:45
 * @description add your comment
 */

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.annotation.Autowired;

public class RAOPTest {
    private static final Log log = LogFactory.getLog(RAOPTest.class);
    @Autowired
    private RAOPUser raopUser;

    public static void testAOPCode(){
        RAOPUser raopUser = new RAOPUser();
        raopUser.setName("raohj");
        raopUser.setAge("32");
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.addAdvice(new RAOPCode());
        proxyFactory.setTarget(raopUser);

        RAOPUser agentProxy = (RAOPUser) proxyFactory.getProxy();
        log.debug(raopUser.toJson());
        log.debug(agentProxy.toJson());
    }

    public void test(){
        raopUser.setName("your name");
    }
}
